package com.wushi.lenovo.asia5b.app_ui.profile.adapter;

import android.support.annotation.Nullable;
import android.text.TextUtils;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wushi.lenovo.asia5b.R;
import com.wushi.lenovo.asia5b.app_model.profile.AddressModel;

import java.util.List;

/**
 * Created by zhangyuncai on 2019/1/25.
 */
public class ChangeAddressAdapter extends BaseQuickAdapter<AddressModel, BaseViewHolder> {
    public ChangeAddressAdapter(@Nullable List<AddressModel> data) {
        super(R.layout.item_changeaddress_adapter, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, AddressModel item) {
        //标签名
        if (TextUtils.isEmpty(item.getBuilding_name())) {
            helper.setGone(R.id.tv_ship_buildingname, false);
        } else {
            helper.setGone(R.id.tv_ship_buildingname, true);
            helper.setText(R.id.tv_ship_buildingname, item.getBuilding_name());
        }

        //姓名
        helper.setText(R.id.tv_ship_username, item.getContact_name());


        //地址名称
        helper.setText(R.id.tv_ship_address,
                item.getLocalAddressDetail()
        );

        //手机号
        String phone = String.format("+%s%s", item.getCalling_code(), item.getContact_no());
        helper.setText(R.id.tv_ship_phone, phone);
        helper.addOnClickListener(R.id.tv_ship_apply);
    }
}
